const WXAPI = require('apifm-wxapi')
Page({
  data: {
    footer_img: wx.getStorageSync('footer_img'),
    work_img1: wx.getStorageSync('work_img1'),
  },
  onLoad: function (options) {
    const that = this;
    that.setData({
      footer_img: wx.getStorageSync('footer_img'),
      work_img1: wx.getStorageSync('work_img1')
    });
    that.getCategory();
  },
  onShow: function () {

  },


  // 获取分类
  async getCategory() {
    var that = this;
    await WXAPI.goodsCategory().then(function (res) {
      let categories = [];
      if (res.code == 0) {
        for (var i = 0; i < res.data.length; i++) {
          if (res.data[i].pid == "434871" ) {
            categories.push(res.data[i]);
          }
        }

        that.setData({
          category: categories,
        });

      }
    })

  },


  //跳转到列表页面
  toList: function (t) {
    var a = t.currentTarget.dataset.categoryid;
    wx.navigateTo({
      url: "/pages/a1_list/index?categoryId=" + a
    })
  },

  //跳转到详情页面
  toPost: function (t) {
    var a = t.currentTarget.dataset.postid;
    wx.navigateTo({
      url: "/pages/a1_post/index?categoryId=" + a
    })
  },




  //拨打电话
  callPhone() {
    wx.makePhoneCall({
      phoneNumber: wx.getStorageSync('phone')
    })
  },

  // 打开视频号主页
  toVideo() {
    wx.openChannelsUserProfile({
      finderUserName: wx.getStorageSync('sphid'),
    });
  },


  onShareAppMessage() { },
  onShareTimeline() { },
})